<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px" >
      <el-form-item label="商品名称" style="width: 800px">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="商品类型">
        <el-select v-model="form.category" placeholder="请选择活动区域">
          <el-option label="狂欢" value="狂欢"></el-option>
          <el-option label="电视" value="电视"></el-option>
          <el-option label="激光" value="激光"></el-option>
          <el-option label="空调" value="空调"></el-option>
          <el-option label="冰箱" value="冰箱"></el-option>
          <el-option label="洗衣机" value="洗衣机"></el-option>
          <el-option label="冷柜" value="冷柜"></el-option>
          <el-option label="厨卫" value="厨卫"></el-option>
          <el-option label="空净" value="空净"></el-option>
          <el-option label="手机" value="手机"></el-option>
          <el-option label="聚享家" value="聚享家"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="商品ID" style="width: 200px">
        <el-input v-model="form.id"></el-input>
      </el-form-item>
      <el-form-item label="商品图片链接" style="width: 500px">
        <el-input v-model="form.mainImage"></el-input>
      </el-form-item>
      <el-form-item label="销售价格" style="width: 150px">
        <el-input v-model="form.price"></el-input>
      </el-form-item>
      <el-form-item label="上线时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.date1"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-time-picker
            placeholder="选择时间"
            v-model="form.date2"
            style="width: 100%"
          ></el-time-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="虚假销量" style="width: 300px">
        <el-input v-model="form.saleQuantity"></el-input>
      </el-form-item>
      <el-form-item label="商品属性" style="width: 600px">
        <el-input type="textarea" v-model="form.attributes"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="append">添加商品</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  name: "AddGoods",

  data() {
    return {
      form: {
        name: "",
        category: "",
        id: ""*1,
        mainImage: "",
        price: "",
        date2: "",
        attributes: "",
      },
    };
  },
  methods: {
    async append() {
      // console.log(this.form);
      await this.$request.post("/goods/addgoods", {
        goods: {...this.form },
      });
      this.form = {
        category : "",
        name :"",
        
        id : "",
        mainImage :"",
        price : "",
        date2 : "",
        attributes : "",
      }
    },
  },
};
</script>
